<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_Participation extends Application_Model_ModelAbstract
{

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Idparticipation;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_SondageIdsondage;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Scorefinal;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_SondagepersonneIdsondagepersonne;


    /**
     * Parent relation fk_participation_sondage1
     *
     * @var Application_Model_Sondage
     */
    protected $_Sondage;

    /**
     * Parent relation fk_participation_sondagepersonne1
     *
     * @var Application_Model_Sondagepersonne
     */
    protected $_Sondagepersonne;


    /**
     * Dependent relation fk_reponseparticipant_participation1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_Reponseparticipant
     */
    protected $_Reponseparticipant;

    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'idparticipation'=>'Idparticipation',
            'sondage_idsondage'=>'SondageIdsondage',
            'scorefinal'=>'Scorefinal',
            'sondagepersonne_idsondagepersonne'=>'SondagepersonneIdsondagepersonne',
        ));

        $this->setParentList(array(
            'FkParticipationSondage1'=> array(
                    'property' => 'Sondage',
                    'table_name' => 'Sondage',
                ),
            'FkParticipationSondagepersonne1'=> array(
                    'property' => 'Sondagepersonne',
                    'table_name' => 'Sondagepersonne',
                ),
        ));

        $this->setDependentList(array(
            'FkReponseparticipantParticipation1' => array(
                    'property' => 'Reponseparticipant',
                    'table_name' => 'Reponseparticipant',
                ),
        ));
    }

    /**
     * Sets column idparticipation
     *
     * @param int $data
     * @return Application_Model_Participation
     */
    public function setIdparticipation($data)
    {
        $this->_Idparticipation = $data;
        return $this;
    }

    /**
     * Gets column idparticipation
     *
     * @return int
     */
    public function getIdparticipation()
    {
        return $this->_Idparticipation;
    }

    /**
     * Sets column sondage_idsondage
     *
     * @param int $data
     * @return Application_Model_Participation
     */
    public function setSondageIdsondage($data)
    {
        $this->_SondageIdsondage = $data;
        return $this;
    }

    /**
     * Gets column sondage_idsondage
     *
     * @return int
     */
    public function getSondageIdsondage()
    {
        return $this->_SondageIdsondage;
    }

    /**
     * Sets column scorefinal
     *
     * @param int $data
     * @return Application_Model_Participation
     */
    public function setScorefinal($data)
    {
        $this->_Scorefinal = $data;
        return $this;
    }

    /**
     * Gets column scorefinal
     *
     * @return int
     */
    public function getScorefinal()
    {
        return $this->_Scorefinal;
    }

    /**
     * Sets column sondagepersonne_idsondagepersonne
     *
     * @param int $data
     * @return Application_Model_Participation
     */
    public function setSondagepersonneIdsondagepersonne($data)
    {
        $this->_SondagepersonneIdsondagepersonne = $data;
        return $this;
    }

    /**
     * Gets column sondagepersonne_idsondagepersonne
     *
     * @return int
     */
    public function getSondagepersonneIdsondagepersonne()
    {
        return $this->_SondagepersonneIdsondagepersonne;
    }

    /**
     * Sets parent relation SondageIdsondage
     *
     * @param Application_Model_Sondage $data
     * @return Application_Model_Participation
     */
    public function setSondage(Application_Model_Sondage $data)
    {
        $this->_Sondage = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idsondage'];
        }

        $this->setSondageIdsondage($primary_key);

        return $this;
    }

    /**
     * Gets parent SondageIdsondage
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Sondage
     */
    public function getSondage($load = true)
    {
        if ($this->_Sondage === null && $load) {
            $this->getMapper()->loadRelated('FkParticipationSondage1', $this);
        }

        return $this->_Sondage;
    }

    /**
     * Sets parent relation SondagepersonneIdsondagepersonne
     *
     * @param Application_Model_Sondagepersonne $data
     * @return Application_Model_Participation
     */
    public function setSondagepersonne(Application_Model_Sondagepersonne $data)
    {
        $this->_Sondagepersonne = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idsondagepersonne'];
        }

        $this->setSondagepersonneIdsondagepersonne($primary_key);

        return $this;
    }

    /**
     * Gets parent SondagepersonneIdsondagepersonne
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Sondagepersonne
     */
    public function getSondagepersonne($load = true)
    {
        if ($this->_Sondagepersonne === null && $load) {
            $this->getMapper()->loadRelated('FkParticipationSondagepersonne1', $this);
        }

        return $this->_Sondagepersonne;
    }

    /**
     * Sets dependent relations fk_reponseparticipant_participation1
     *
     * @param array $data An array of Application_Model_Reponseparticipant
     * @return Application_Model_Participation
     */
    public function setReponseparticipant(array $data)
    {
        $this->_Reponseparticipant = array();

        foreach ($data as $object) {
            $this->addReponseparticipant($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_reponseparticipant_participation1
     *
     * @param Application_Model_Reponseparticipant $data
     * @return Application_Model_Participation
     */
    public function addReponseparticipant(Application_Model_Reponseparticipant $data)
    {
        $this->_Reponseparticipant[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_reponseparticipant_participation1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_Reponseparticipant
     */
    public function getReponseparticipant($load = true)
    {
        if ($this->_Reponseparticipant === null && $load) {
            $this->getMapper()->loadRelated('FkReponseparticipantParticipation1', $this);
        }

        return $this->_Reponseparticipant;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_Participation
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_Participation());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_Participation::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIdparticipation() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('idparticipation = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIdparticipation()));
    }
}
